<template>
  <div>
      <div
      style="line-height: 40px; font-size: 22px; font-weight: 600; padding: 5px"
    >
      事件查重
    </div>
    <el-card class="box-card">
      <el-row>
        <el-col :span="2">
          <el-input v-model="value" placeholder="选择事件类型" size="mini" class="top-ipt"></el-input>
        </el-col>
        <el-col :span="2">
          <el-select v-model="value" placeholder="选择发生科室" size="mini" class="top-ipt">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-select v-model="value" placeholder="选择上报科室" size="mini" class="top-ipt">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-select v-model="value" placeholder="选择事件等级" size="mini" class="top-ipt">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-date-picker v-model="value" align="right" type="date" placeholder="发生日期起" size="mini" style="width:140px;margin-left:5px;">
          </el-date-picker>
        </el-col>
        <el-col :span="2">
          <el-date-picker v-model="value" align="right" type="date" placeholder="发生日期至" size="mini" style="width:140px;margin-left:5px;">
          </el-date-picker>
        </el-col>
        <el-col :span="2">
          <el-select v-model="value" placeholder="患者姓名" size="mini" class="top-ipt">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-select v-model="value" placeholder="事件编号" size="mini" class="top-ipt">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
       
        <el-col :span="4">
          <el-button type="primary" icon="el-icon-search" size="mini" style="float:right;">搜索</el-button>
        </el-col>
      </el-row>
    </el-card>
     <el-button
          type="primary"
          size="mini"
          icon="el-icon-s-grid"
          style="margin: 10px 10px; float: right; margin-right: 20px"
          v-if="btnShow"
          @click="btnClick"
        >
        </el-button>
        <el-select
          v-model="value1"
          size="mini"
          multiple
          collapse-tags
          @change="selectChange"
          v-if="disShow"
          style="float: right; margin-right: 20px"
        >
          <el-option
            v-for="item in tableDataLabel"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
    <el-table :data="tableData" style="width: 96%;margin:0 auto;">
       <el-table-column
            :prop="item.prop"
            :label="item.label"
            v-for="(item, id) in tableList"
            :key="id"
          />
    </el-table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: "",
      value1: [],
      disShow: false,
      btnShow: true,
      tableDataLabel: [
         {
          value: "1",
          label: "事件编号",
          prop: "name",
        },
        {
          value: "2",
          label: "事件类型",
          prop: "name",
        },
        {
          value: "3",
          label: "事件等级",
          prop: "name",
        },
        {
          value: "4",
          label: "患者姓名",
          prop: "name",
        },
        {
          value: "5",
          label: "发生科室",
          prop: "name",
        },
        {
          value: "6",
          label: "发生时间",
          prop: "name",
        },
        {
          value: "7",
          label: "上报人",
          prop: "name",
        },
        {
          value: "8",
          label: "追踪状态",
          prop: "name",
        },
        {
          value: "9",
          label: "操作",
          prop: "name",
        },
      ],
      tableList: [
         {
          value: "1",
          label: "事件编号",
          prop: "name",
        },
        {
          value: "2",
          label: "事件类型",
          prop: "name",
        },
        {
          value: "3",
          label: "事件等级",
          prop: "name",
        },
        {
          value: "4",
          label: "患者姓名",
          prop: "name",
        },
        {
          value: "5",
          label: "发生科室",
          prop: "name",
        },
        {
          value: "6",
          label: "发生时间",
          prop: "name",
        },
        {
          value: "7",
          label: "上报人",
          prop: "name",
        },
        {
          value: "8",
          label: "追踪状态",
          prop: "name",
        },
        {
          value: "9",
          label: "操作",
          prop: "name",
        },
      ],
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
      options: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
    };
  },
  methods: {
    selectChange(val) {
      this.tableList = [];
      this.departmentIds = []; //初始化数据
      this.departmentNames = []; //初始化数据
      for (let i = 0; i <= val.length - 1; i++) {
        this.tableDataLabel.find((item) => {
          //这里的tableDataLabel就是数据源
          if (item.value == val[i]) {
            this.tableList.push({
              value: item.value,
              label: item.label,
              prop: item.prop,
            });
          }
        });
      }
      console.log(this.tableList);
    },
    btnClick() {
      this.disShow = !this.disShow;
      this.btnShow = !this.btnShow;
    },
  },
};
</script>
<style scoped>
body {
  background-color: #f8f9fa;
}
.box-card {
  margin: 5px;
}
.el-card /deep/ .el-card__header {
  padding: 10px 20px;
  background-color: #e2e2e2;
}
.top-ipt {
  margin-left: 5px;
}
</style>